package test06.stream.demo02.t09;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author ZQX
 * @date 2025-04-08
 */
public class MainTest05 {
    public static void main(String[] args) {
        // 第一：定义数据源，并获取对应的流对象
        Student s1 = new Student("张三","男",18,55) ;
        Student s2 = new Student("李四","女",28,63) ;
        Student s3 = new Student("王五","男",38,50) ;
        Student s4 = new Student("赵六","女",48,99) ;
        List<Student> list = Arrays.asList(s1,s2,s3,s4);

        // 第二：操作 - 分区操作
        Map<Boolean, List<Student>> map = list.stream()
                .collect(Collectors.partitioningBy(s ->s.getScore() >= 60)
        );

        map.forEach((k,v)->{
            System.out.println(k + ":"+v);
        });

    }
}
